package cn.itcast.com.Thread;

import lombok.SneakyThrows;

//等待该线程终止
public class join {

    public static void main(String[] args) throws InterruptedException {
        jointhread jointhread = new jointhread();
        jointhread.start();

        jointhread.join();
        //join这个方法会等待调用这个方法的线程先执行完毕
        //然后再执行其他的
        System.out.println("main end");
    }

}

class jointhread extends Thread{
    @SneakyThrows
    public void run(){
        System.out.println("begin");
        Thread.sleep(5000);
        System.out.println("end");
    }
}
